﻿using System;
using System.Data;
using System.Windows.Forms;
using FarPoint.Win.Spread;
using FarPoint.Win.Spread.Data;
using FarPoint.Win.Spread.Model;
using Spread.Common.DataStore;

namespace Spread.Table.Features
{
    public partial class CustomTable : Spread.Common.Features.Sample.BaseSampleControl
    {
        #region Fields
        private bool isTableSelected;
        private AccessDataSource _dataSource;
        private static int tableNumber = 2;
        #endregion

        #region ctor
        public CustomTable()
        {
            InitializeComponent();
            Name = "Custom Table";

            _dataSource = new DataService().AccessDataSource;

            pnlControls.HorizontalScroll.Maximum = 0;
            pnlControls.AutoScroll = false;
            pnlControls.VerticalScroll.Visible = false;
            pnlControls.AutoScroll = true;

            SetSheetProperties(fpSpread.ActiveSheet);
            AddSampleTable(fpSpread.ActiveSheet);
            fpSpread.SelectionChanged += FpSpread_SelectionChanged;

            txtColumnFrom.TextChanged += MoveTableColumnParametersChanged;
            txtColumnTo.TextChanged += MoveTableColumnParametersChanged;
            txtColMoveCount.TextChanged += MoveTableColumnParametersChanged;

            txtRowFrom.TextChanged += MoveTableRowParametersChanged;
            txtRowTo.TextChanged += MoveTableRowParametersChanged;
            txtRowMoveCount.TextChanged += MoveTableRowParametersChanged;

            txtRowCount.TextChanged += ResizeTableParametersChanged;
            txtColumnCount.TextChanged += ResizeTableParametersChanged;

            btnMoveRows.Click += BtnMoveRows_Click;
            btnMoveCols.Click += BtnMoveCols_Click;
            btnAddTable.Click += BtnAddTable_Click;
            btnRemoveTable.Click += BtnRemoveTable_Click;
            btnResizeTable.Click += BtnResizeTable_Click;
        }
        #endregion

        #region Private methods
        private void SetSheetProperties(SheetView sheet)
        {
            fpSpread.StatusBarVisible = true;
            sheet.SetMultipleRowHeights(0, sheet.RowCount, 20);
        }

        private void AddSampleTable(SheetView sheet)
        {
            DataTable dataTable = _dataSource.GetDataFromTable("Nwind.mdb", "Products").Tables[0];
            SpreadDataBindingAdapter adapter = new SpreadDataBindingAdapter();
            adapter.Spread = fpSpread;
            adapter.SheetName = "Sheet1";
            adapter.DataSource = dataTable;
            adapter.MapperInfo = new MapperInfo(2, 1, 30, dataTable.Columns.Count);
            adapter.FillSpreadDataByDataSource();

            int col = 1;
            foreach (DataColumn column in dataTable.Columns)
                sheet.Cells[1, col++].Text = (column.Caption);

            TableView table = sheet.AddTable("Table1", 1, 1, 31, dataTable.Columns.Count,
                TableStyle.TableStyleMedium2);

            for (int j = 1; j < col; ++j)
                sheet.Columns[j].Width = sheet.Columns[j].GetPreferredWidth();
        }

        private void ToggleButtons()
        {
            CellRange range = fpSpread.ActiveSheet.GetSelection(0);
            TableView table = fpSpread.ActiveSheet.GetTable(range.Row, range.Column);
            isTableSelected = table != null;
            txtTableName.Text = isTableSelected ? table.Name : string.Empty;
            btnRemoveTable.Enabled = isTableSelected;
            btnAddTable.Enabled = !isTableSelected;

            ToggleButtonState(btnMoveRows, txtRowFrom, txtRowTo, txtRowMoveCount);
            ToggleButtonState(btnMoveCols, txtColumnFrom, txtColumnTo, txtColMoveCount);
            ToggleButtonState(btnResizeTable, txtRowCount, txtColumnCount);
        }

        private void ToggleButtonState(Button button, params TextBox[] textBoxes)
        {
            foreach (var textBox in textBoxes)
            {
                //int value = 0;
                if (textBox.Text == string.Empty || !int.TryParse(textBox.Text, out int value))
                {
                    button.Enabled = false;
                    return;
                }
            }
            button.Enabled = isTableSelected;
        }
        #endregion

        #region Event handlers
        private void FpSpread_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ToggleButtons();
        }

        private void BtnAddTable_Click(object sender, EventArgs e)
        {
            CellRange range = fpSpread.ActiveSheet.GetSelection(0);
            if (range == null)
            {
                MessageBox.Show("Select a valid cell range", "Invalid Selection", MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }
            string tableName = txtTableName.Text;
            if (tableName == string.Empty)
            {
                tableName = $"Table{tableNumber++}";
            }

            try
            {
                fpSpread.ActiveSheet.AddTable(tableName, range.Row, range.Column, range.RowCount,
                    range.ColumnCount, TableStyle.TableStyleLight1);
                txtTableName.Text = tableName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error adding table", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void BtnRemoveTable_Click(object sender, EventArgs e)
        {
            Cell activeCell = fpSpread.ActiveSheet.ActiveCell;
            TableView table = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index);
            CellRange range = table.DataRange;
            fpSpread.ActiveSheet.RemoveTable(table.Name);
            ToggleButtons();

            fpSpread.ActiveSheet.Cells[range.Row, range.Column, range.Row + range.RowCount - 1,
                range.Column + range.ColumnCount - 1].ResetValue();
        }

        private void BtnMoveRows_Click(object sender, EventArgs e)
        {
            int rowFrom = int.Parse(txtRowFrom.Text);
            int rowTo = int.Parse(txtRowTo.Text);
            int rowCount = int.Parse(txtRowMoveCount.Text);

            Cell activeCell = fpSpread.ActiveSheet.ActiveCell;
            TableView table = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index);

            try
            {
                table.MoveTableRows(rowFrom, rowTo, rowCount);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error moving rows", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void BtnMoveCols_Click(object sender, EventArgs e)
        {
            int colFrom = int.Parse(txtColumnFrom.Text);
            int colTo = int.Parse(txtColumnTo.Text);
            int colCount = int.Parse(txtColMoveCount.Text);

            Cell activeCell = fpSpread.ActiveSheet.ActiveCell;
            TableView table = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index);

            try
            {
                table.MoveTableColumns(colFrom, colTo, colCount);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error moving columns", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void BtnResizeTable_Click(object sender, EventArgs e)
        {
            int rowCount = int.Parse(txtRowCount.Text);
            int colCount = int.Parse(txtColumnCount.Text);
            Cell activeCell = fpSpread.ActiveSheet.ActiveCell;
            TableView table = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index);

            try
            {
                table.Resize(rowCount, colCount);
                ToggleButtons();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error resizing table", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void MoveTableColumnParametersChanged(object sender, EventArgs e)
        {
            ToggleButtonState(btnMoveCols, txtColumnFrom, txtColumnTo, txtColMoveCount);
        }

        private void MoveTableRowParametersChanged(object sender, EventArgs e)
        {
            ToggleButtonState(btnMoveRows, txtRowFrom, txtRowTo, txtRowMoveCount);
        }

        private void ResizeTableParametersChanged(object sender, EventArgs e)
        {
            ToggleButtonState(btnResizeTable, txtRowCount, txtColumnCount);
        }
        #endregion
    }
}


//
//CustomTable.Designer.cs
//


namespace Spread.Table.Features
{
    partial class CustomTable
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.fpSpread = new FarPoint.Win.Spread.FpSpread();
            this.fpSpread_Sheet1 = new FarPoint.Win.Spread.SheetView();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txtTableName = new System.Windows.Forms.TextBox();
            this.btnRemoveTable = new System.Windows.Forms.Button();
            this.btnAddTable = new System.Windows.Forms.Button();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.txtRowFrom = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.btnMoveRows = new System.Windows.Forms.Button();
            this.txtColumnFrom = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.txtRowTo = new System.Windows.Forms.TextBox();
            this.label10 = new System.Windows.Forms.Label();
            this.txtRowMoveCount = new System.Windows.Forms.TextBox();
            this.label11 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.txtColumnTo = new System.Windows.Forms.TextBox();
            this.label13 = new System.Windows.Forms.Label();
            this.txtColMoveCount = new System.Windows.Forms.TextBox();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.label8 = new System.Windows.Forms.Label();
            this.btnResizeTable = new System.Windows.Forms.Button();
            this.label7 = new System.Windows.Forms.Label();
            this.txtColumnCount = new System.Windows.Forms.TextBox();
            this.txtRowCount = new System.Windows.Forms.TextBox();
            this.btnMoveCols = new System.Windows.Forms.Button();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread_Sheet1)).BeginInit();
            this.groupBox1.SuspendLayout();
            this.tableLayoutPanel2.SuspendLayout();
            this.tableLayoutPanel3.SuspendLayout();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.fpSpread);
            this.pnlMain.Controls.Add(this.tableLayoutPanel1);
            this.pnlMain.Size = new System.Drawing.Size(456, 527);
            // 
            // pnlControls
            // 
            this.pnlControls.Controls.Add(this.tableLayoutPanel3);
            this.pnlControls.Controls.Add(this.tableLayoutPanel2);
            this.pnlControls.Controls.Add(this.btnMoveCols);
            this.pnlControls.Controls.Add(this.groupBox1);
            this.pnlControls.Controls.Add(this.txtColMoveCount);
            this.pnlControls.Controls.Add(this.label13);
            this.pnlControls.Controls.Add(this.txtRowMoveCount);
            this.pnlControls.Controls.Add(this.label10);
            this.pnlControls.Controls.Add(this.btnMoveRows);
            this.pnlControls.Controls.Add(this.label5);
            this.pnlControls.Controls.Add(this.label3);
            this.pnlControls.Controls.Add(this.btnAddTable);
            this.pnlControls.Controls.Add(this.btnRemoveTable);
            this.pnlControls.Controls.Add(this.txtTableName);
            this.pnlControls.Controls.Add(this.label2);
            this.pnlControls.Controls.Add(this.label1);
            this.pnlControls.Size = new System.Drawing.Size(151, 527);
            // 
            // fpSpread
            // 
            this.fpSpread.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread.Location = new System.Drawing.Point(0, 0);
            this.fpSpread.Name = "fpSpread";
            this.fpSpread.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.fpSpread_Sheet1});
            this.fpSpread.Size = new System.Drawing.Size(456, 527);
            this.fpSpread.TabIndex = 0;
            // 
            // fpSpread_Sheet1
            // 
            this.fpSpread_Sheet1.Reset();
            this.fpSpread_Sheet1.SheetName = "Sheet1";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(5, 24);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(185, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Please select the table area on sheet:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(5, 47);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(68, 13);
            this.label2.TabIndex = 1;
            this.label2.Text = "Table Name:";
            // 
            // txtTableName
            // 
            this.txtTableName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTableName.Location = new System.Drawing.Point(7, 63);
            this.txtTableName.Name = "txtTableName";
            this.txtTableName.Size = new System.Drawing.Size(129, 20);
            this.txtTableName.TabIndex = 2;
            // 
            // btnRemoveTable
            // 
            this.btnRemoveTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.btnRemoveTable.Enabled = false;
            this.btnRemoveTable.Location = new System.Drawing.Point(20, 89);
            this.btnRemoveTable.Name = "btnRemoveTable";
            this.btnRemoveTable.Size = new System.Drawing.Size(99, 23);
            this.btnRemoveTable.TabIndex = 3;
            this.btnRemoveTable.Text = "Remove Table";
            this.btnRemoveTable.UseVisualStyleBackColor = true;
            // 
            // btnAddTable
            // 
            this.btnAddTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.btnAddTable.Location = new System.Drawing.Point(20, 118);
            this.btnAddTable.Name = "btnAddTable";
            this.btnAddTable.Size = new System.Drawing.Size(99, 23);
            this.btnAddTable.TabIndex = 4;
            this.btnAddTable.Text = "Add Table";
            this.btnAddTable.UseVisualStyleBackColor = true;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(5, 151);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(67, 13);
            this.label3.TabIndex = 5;
            this.label3.Text = "Move Rows:";
            // 
            // label4
            // 
            this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left;
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(3, 8);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(33, 13);
            this.label4.TabIndex = 7;
            this.label4.Text = "From:";
            // 
            // txtRowFrom
            // 
            this.txtRowFrom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.txtRowFrom.Location = new System.Drawing.Point(45, 4);
            this.txtRowFrom.Name = "txtRowFrom";
            this.txtRowFrom.Size = new System.Drawing.Size(26, 20);
            this.txtRowFrom.TabIndex = 6;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(5, 260);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(80, 13);
            this.label5.TabIndex = 10;
            this.label5.Text = "Move Columns:";
            // 
            // btnMoveRows
            // 
            this.btnMoveRows.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.btnMoveRows.Enabled = false;
            this.btnMoveRows.Location = new System.Drawing.Point(20, 228);
            this.btnMoveRows.Name = "btnMoveRows";
            this.btnMoveRows.Size = new System.Drawing.Size(99, 23);
            this.btnMoveRows.TabIndex = 9;
            this.btnMoveRows.Text = "Move Rows";
            this.btnMoveRows.UseVisualStyleBackColor = true;
            // 
            // txtColumnFrom
            // 
            this.txtColumnFrom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.txtColumnFrom.Location = new System.Drawing.Point(45, 4);
            this.txtColumnFrom.Name = "txtColumnFrom";
            this.txtColumnFrom.Size = new System.Drawing.Size(26, 20);
            this.txtColumnFrom.TabIndex = 11;
            // 
            // label9
            // 
            this.label9.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(77, 8);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(23, 13);
            this.label9.TabIndex = 15;
            this.label9.Text = "To:";
            // 
            // txtRowTo
            // 
            this.txtRowTo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.txtRowTo.Location = new System.Drawing.Point(107, 4);
            this.txtRowTo.Name = "txtRowTo";
            this.txtRowTo.Size = new System.Drawing.Size(27, 20);
            this.txtRowTo.TabIndex = 7;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(5, 203);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(38, 13);
            this.label10.TabIndex = 17;
            this.label10.Text = "Count:";
            // 
            // txtRowMoveCount
            // 
            this.txtRowMoveCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtRowMoveCount.Location = new System.Drawing.Point(50, 200);
            this.txtRowMoveCount.Name = "txtRowMoveCount";
            this.txtRowMoveCount.Size = new System.Drawing.Size(89, 20);
            this.txtRowMoveCount.TabIndex = 8;
            // 
            // label11
            // 
            this.label11.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(4, 8);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(33, 13);
            this.label11.TabIndex = 19;
            this.label11.Text = "From:";
            // 
            // label12
            // 
            this.label12.Anchor = System.Windows.Forms.AnchorStyles.None;
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(77, 8);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(23, 13);
            this.label12.TabIndex = 20;
            this.label12.Text = "To:";
            // 
            // txtColumnTo
            // 
            this.txtColumnTo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
            this.txtColumnTo.Location = new System.Drawing.Point(107, 4);
            this.txtColumnTo.Name = "txtColumnTo";
            this.txtColumnTo.Size = new System.Drawing.Size(27, 20);
            this.txtColumnTo.TabIndex = 12;
            // 
            // label13
            // 
            this.label13.AutoSize = true;
            this.label13.Location = new System.Drawing.Point(5, 316);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(38, 13);
            this.label13.TabIndex = 22;
            this.label13.Text = "Count:";
            // 
            // txtColMoveCount
            // 
            this.txtColMoveCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtColMoveCount.Location = new System.Drawing.Point(50, 313);
            this.txtColMoveCount.Name = "txtColMoveCount";
            this.txtColMoveCount.Size = new System.Drawing.Size(89, 20);
            this.txtColMoveCount.TabIndex = 13;
            // 
            // groupBox1
            // 
            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBox1.Controls.Add(this.label8);
            this.groupBox1.Controls.Add(this.btnResizeTable);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.txtColumnCount);
            this.groupBox1.Controls.Add(this.txtRowCount);
            this.groupBox1.Location = new System.Drawing.Point(0, 380);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(139, 139);
            this.groupBox1.TabIndex = 24;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Resize Table";
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(5, 61);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(75, 13);
            this.label8.TabIndex = 19;
            this.label8.Text = "Column count:";
            // 
            // btnResizeTable
            // 
            this.btnResizeTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.btnResizeTable.Enabled = false;
            this.btnResizeTable.Location = new System.Drawing.Point(20, 103);
            this.btnResizeTable.Name = "btnResizeTable";
            this.btnResizeTable.Size = new System.Drawing.Size(99, 23);
            this.btnResizeTable.TabIndex = 17;
            this.btnResizeTable.Text = "Resize Table";
            this.btnResizeTable.UseVisualStyleBackColor = true;
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(5, 23);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(62, 13);
            this.label7.TabIndex = 17;
            this.label7.Text = "Row count:";
            // 
            // txtColumnCount
            // 
            this.txtColumnCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtColumnCount.Location = new System.Drawing.Point(8, 77);
            this.txtColumnCount.Name = "txtColumnCount";
            this.txtColumnCount.Size = new System.Drawing.Size(131, 20);
            this.txtColumnCount.TabIndex = 16;
            // 
            // txtRowCount
            // 
            this.txtRowCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txtRowCount.Location = new System.Drawing.Point(8, 39);
            this.txtRowCount.Name = "txtRowCount";
            this.txtRowCount.Size = new System.Drawing.Size(131, 20);
            this.txtRowCount.TabIndex = 15;
            // 
            // btnMoveCols
            // 
            this.btnMoveCols.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.btnMoveCols.Enabled = false;
            this.btnMoveCols.Location = new System.Drawing.Point(20, 340);
            this.btnMoveCols.Name = "btnMoveCols";
            this.btnMoveCols.Size = new System.Drawing.Size(99, 23);
            this.btnMoveCols.TabIndex = 14;
            this.btnMoveCols.Text = "Move Columns";
            this.btnMoveCols.UseVisualStyleBackColor = true;
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.Location = new System.Drawing.Point(237, 219);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 100);
            this.tableLayoutPanel1.TabIndex = 16;
            // 
            // tableLayoutPanel2
            // 
            this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tableLayoutPanel2.ColumnCount = 4;
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 42F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.Controls.Add(this.txtRowTo, 3, 0);
            this.tableLayoutPanel2.Controls.Add(this.label9, 2, 0);
            this.tableLayoutPanel2.Controls.Add(this.label4, 0, 0);
            this.tableLayoutPanel2.Controls.Add(this.txtRowFrom, 1, 0);
            this.tableLayoutPanel2.Location = new System.Drawing.Point(5, 165);
            this.tableLayoutPanel2.Name = "tableLayoutPanel2";
            this.tableLayoutPanel2.RowCount = 1;
            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel2.Size = new System.Drawing.Size(137, 29);
            this.tableLayoutPanel2.TabIndex = 25;
            // 
            // tableLayoutPanel3
            // 
            this.tableLayoutPanel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tableLayoutPanel3.ColumnCount = 4;
            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 42F));
            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel3.Controls.Add(this.label11, 0, 0);
            this.tableLayoutPanel3.Controls.Add(this.txtColumnFrom, 1, 0);
            this.tableLayoutPanel3.Controls.Add(this.label12, 2, 0);
            this.tableLayoutPanel3.Controls.Add(this.txtColumnTo, 3, 0);
            this.tableLayoutPanel3.Location = new System.Drawing.Point(5, 278);
            this.tableLayoutPanel3.Name = "tableLayoutPanel3";
            this.tableLayoutPanel3.RowCount = 1;
            this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel3.Size = new System.Drawing.Size(137, 29);
            this.tableLayoutPanel3.TabIndex = 17;
            // 
            // CustomTable
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "CustomTable";
            this.Size = new System.Drawing.Size(608, 527);
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            this.pnlControls.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread_Sheet1)).EndInit();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.tableLayoutPanel2.ResumeLayout(false);
            this.tableLayoutPanel2.PerformLayout();
            this.tableLayoutPanel3.ResumeLayout(false);
            this.tableLayoutPanel3.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread fpSpread;
        private FarPoint.Win.Spread.SheetView fpSpread_Sheet1;
        private System.Windows.Forms.Button btnMoveRows;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox txtColumnFrom;
        private System.Windows.Forms.TextBox txtRowFrom;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button btnAddTable;
        private System.Windows.Forms.Button btnRemoveTable;
        private System.Windows.Forms.TextBox txtTableName;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox txtRowTo;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.TextBox txtColMoveCount;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.TextBox txtColumnTo;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.TextBox txtRowMoveCount;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.Button btnMoveCols;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Button btnResizeTable;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.TextBox txtColumnCount;
        private System.Windows.Forms.TextBox txtRowCount;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
    }
}
